<div id="main">
    <div class="section_ads">
        <h3><?php echo $this->translate('last gifts published');?></h3>
            <?php if ($this->allGives): ?>
                   <?php
                   foreach ($this->allGives as $key => $val): ?>
                    <div class="ad_excerpt_home">
                      <?php
                       if ($val['photo'] !== null){
                                  echo '<div class="ad_list_image">
                                  <a href="/'.$this->lang.'/ad/show/id/'.$this->escape($val['id']).'/'.$this->escape($val['title']).' ">
                                  <img alt="'.$this->escape($val['title']).'" src="/images/uploads/ads/100/'.
                                  $this->escape($val['photo']).'" /></a></div>';
                       }
                      
                        // if you are the ad owner or admin, then show edit link
                         $auth = Zend_Auth::getInstance ();
                        if ( ($val['user_owner'] == $auth->getIdentity()->id)  || ($this->userRole == 1) ): ?>
                         <div>
                        <a href="/<?=$this->lang ?>/ad/edit/id/<?=$val['id'] ?>">
                                    <img alt="<?=$this->translate('Edit this ad') ?>" src="/images/edit_ad.png"/>&nbsp;<?=$this->translate('Edit this ad') ?></a>
                         </div><br />
                        <?php endif;?>

                         <div class="ad_excerpt_title"><a href="/<?=$this->lang ?>/ad/show/id/<?=$this->escape($val['id']).'/'.$this->escape($val['title']) ?>">
                       <?=$this->escape($val['title']) ?></a></div>

                      <div class="ad_excerpt_woeid"><a href="/<?=$this->lang.'/woeid/'.$val['woeid_code'].'/give' ?>">
                         <?=$this->woeidName($val['woeid_code'], $this->lang).' > '. $this->translate('give') ?> </a></div>

                        <?php if ($val['type'] == 1): ?>
                       <span class="ad_status <?=$val['status'] ?>"><?=$this->translate($val['status']) ?></span>
                        <?php endif;?>

                        <span class="ad_date"><?=$this->translate('Posted on '). $this->escape(date( $this->translate('l dS \o\f F Y H:i:s'), strtotime($val['date_created']))) ?>
                        <?=$this->translate('by user ') ?>
                        <a href="/<?=$this->lang ?>/ad/listuser/id/<?=$val['user_owner'] ?>"><?=$this->escape($val['username']) ?></a>
                        </span>

                       <div><p><?php echo $this->escapeEmail( $this->escape($val['body']) ) ?></p></div>


                        <div class="ad_meta_info">
                <?php if ($val['status'] != 'delivered'): ?>
               <b><a rel="nofollow" href="/<?=$this->lang ?>/message/create/id_user_to/<?=$val['user_owner'].'/subject/'.$this->escape($val['title'])
                   ?>">+ <?=$this->translate('Send message to the owner') ?></a></b>
               &nbsp;&nbsp;&nbsp;<b><a href="/<?=$this->lang ?>/ad/show/id/<?=$this->escape($val['id']).'/'.$this->escape($val['title'])
                   ?>">+ <?=$this->translate('Write a new comment') ?></a></b>
                    <?php endif;?>

               <?php if ($val['readings_count']): ?>&nbsp;&nbsp;
                    <?=$val['readings_count'] . '&nbsp;&nbsp;' .$this->translate('readings') ?>
                <?php endif;?>

                <?php if ($val['comments_count']): ?>
                     <?=', '.$this->escape( $val['comments_count'] == null  ? 0 : $val['comments_count'] ).' '.$this->translate('comments') ?>
                 <?php endif;?>
           </div>
                    </div>

                    <?php endforeach; ?>
        <br />
        <b><a href="/<?php echo $this->lang ?>/ad/listall/ad_type/give/page/2"><?php echo $this->translate('view more ads')?> > </a></b>
                <?php endif;?>
    </div>


    <div class="section_locations">
        <h3><?php echo $this->translate('most generous cities');?></h3>
        <br>

        <?php
        //Zend_Debug::dump($this->rankingWoeid);
        if ($this->rankingWoeid): ?>
        <ul>
                   <?php  foreach ($this->rankingWoeid as $key => $val): ?>
            <li>
                <a href="/<?=$this->lang.'/woeid/'.$val['woeid_code'].'/give' ?>">
                         <?=$this->woeidName($val['woeid_code'], $this->lang) . ' (' .$val['ads_count']. ')'?> </a>
            </li>
                    <?php endforeach; ?>
            </ul>
       <?php endif;?>

        </div>
        <div class="section_users">
        <h3><?php echo $this->translate('most generous users');?></h3>
        <br>
        <?php if ($this->rankingUsers): ?>
        <ul>
                   <?php  foreach ($this->rankingUsers as $key => $val): ?>
            <li>
                <a href="/<?=$this->lang.'/ad/listuser/id/'.$val['user_owner'] ?>">
                         <?=$val['user_name'] . ' (' .$val['ads_count']. ')'?> </a>
            </li>
                    <?php endforeach; ?>
            </ul>
       <?php endif;?>

    </div>


</div> <!-- /main -->

